Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Text
Imports System.Collections.Generic

Namespace FBMLSample
	Partial Public Class newsmiley
		Inherits BasePage
		Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)
			Me.Master.RequireLogin = True
			Master.SetSelectedTab("newsmiley")
		End Sub
		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			Dim moods = getMoods()
			lblSetCount.Text = BuildSetCount()
			lblfeedHandler.Text = BuildFeedHandlerForm()
			lblEmoticonGrid.Text = BuildEmoticonGrid(moods,Master.callback,Master.suffix)

		End Sub
		Private Function BuildFeedHandlerForm() As String
			Return String.Format("<form fbtype=""feedStory"" action=""{0}handlers/feedHandler.aspx"">", Master.callback)
		End Function
		Private Function BuildSetCount() As String
            Dim setCount = If((Not String.IsNullOrEmpty(Me.Master.API.data.getUserPreference(2))), Integer.Parse(Me.Master.API.data.getUserPreference(2)), 0)
			If setCount > 1 Then
				Return String.Format("<h3>You've set your mood {0} times in the past.</h3>", setCount)
			End If
			If setCount > 0 Then
				Return String.Format("<h3>You've set your mood {0} time in the past.</h3>", setCount)
			Else
				Return "You've never set your mood before."
			End If
		End Function
	End Class
End Namespace
